package com.jtroom.user.service.impl;

import javax.persistence.Query;

import org.springframework.stereotype.Service;

import com.jtroom.base.DaoSupport;
import com.jtroom.user.entity.User;
import com.jtroom.user.service.UserService;

@Service
public class UserServiceImpl extends DaoSupport<User> implements UserService {

	@Override
	public boolean login(String username, String password) {
		boolean result = false;
		Query query = em.createQuery(" select count(o) from User o where o.username = ?1 and o.password = ?2 and o.enable = true");
		query.setParameter(1, username);
		query.setParameter(2, password);
		long count = (Long) query.getSingleResult();
		if(count == 1) {
			result = true;
		}
		return result;
	}

}
